package com.cxt.model;

import com.cxt.coordinateConversion.ConversionType;
import com.cxt.coordinateConversion.CoordinateAutoConversion;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@CoordinateAutoConversion(type = ConversionType.OBJECT)
public class Coordinate implements Serializable {
    @CoordinateAutoConversion(type = ConversionType.BigDecimalLng)
    private BigDecimal lng;
    @CoordinateAutoConversion(type = ConversionType.BigDecimalLat)
    private BigDecimal lat;

    public BigDecimal getLng() {
        return lng.setScale(6, RoundingMode.HALF_UP);
    }
    public BigDecimal getLat() {
        return lat.setScale(6, RoundingMode.HALF_UP);
    }
}
